const http = uni.$u.http
import Store from "@/store/index"

import {
	handleParams,
	formatGetParams
} from "@/utils/http/tool"

export const getEventType = (params, config = {}) => http.get(`/system/dict/data/list`, formatGetParams({
	config,
	params
}))

// responsibilities_handle

/**
 * @description 获取大类小类列表
 * @param {String} eventTypePid 事项分类父id：事项分类父id:a.查全部类 b.大类 c.小类
 */
export const getEventCategory = (params, config = {}) => http.get(`/teventyype/teventYypeController/selectTeventYypeList`, formatGetParams({
	config,
	params
}))

/**
 * @description 下一环节处理人(上报用)
 */
export const getTaskProcessor2 = (params, config = {}) => http.get('/flowable/flow/getFlowTaskInfoByTaskId2', formatGetParams({
	config,
	params
}))

/**
 * @description 下一环节处理人(处理人用)
 */
export const getTaskProcessor = (params, config = {}) => http.get('/flowable/flow/getFlowTaskInfoByTaskId', formatGetParams({
	config,
	params
}))

/**
 * @description 工作人员用,获取下一节点处理人是否有权责部门
 * @param {String} bs 事件详情.data.eventSubclass 有值是2 否则为1
 * @param {String} eventTypeId
 */
export const getDutyDept = (params, config = {}) => http.post('/tresponsibilities/tresponsibilitiesController/tResponsibilities', params, handleParams(config))

/**
 * @description 获取权责部门下人员
 * @param {String} deptId 部门id
 */
export const getDeptUsers = (params, config = {}) => http.get('/system/user/list', formatGetParams({
	config,
	params
}))

/**
 * @description 获取网格下处理人信息
 * @param {String} bs 标识 => getTaskProcessor2接口中返回数据的 data.taskData.taskDea1Type值
 * @param {String} id => getTaskProcessor2接口中返回数据的 data.id值
 */
export const getTaskHandler = (params, config = {}) => http.get('/weChatApp/classification1', formatGetParams({
	config,
	params: Object.assign({}, {
		pageNum: 1,
		pageSize: 999999
	}, params)
}))

/**
 * @description 事件上报
 */
export const subEvent = (params, config = {}) => http.post('/weChatApp/insert', params, handleParams(config))

// /weChatApp/task

// getFlowTaskInfoByTaskId2， 下一环节处理人请求接口(上报用) 参数 currentTaskId,lat,lon GET请求

// getFlowTaskInfoByTaskId  下一环节处理人请求接口(处理人员核实用) 参数 currentTaskId,lat,lon GET请求

/**
 * @description 评价列表
 */
export const getRateList = (params, config = {}) => {
	return http.get(`/weChatApp/eventSatisfactionList`, formatGetParams({
		params,
		config
	}));

	return new Promise((resolve) => {
		resolve({
			"total": 6,
			"rows": [{
				"createBy": "25",
				"createTime": "2023-03-20 10:23:51",
				"updateBy": null,
				"updateTime": "2023-03-20 10:23:51",
				"remark": null,
				"delFlag": "0",
				"tenantId": null,
				"eventId": "08478e93d5124b73986e704b5f374489",
				"eventName": "测试事件10",
				"eventTypeId": "10118",
				"eventPeopleNum": 4,
				"eventDescribe": "事件描述10",
				"eventLevel": "1",
				"eventLocation": "哈尔滨市测试地址",
				"eventHandler": "16",
				"eventStatus": "2",
				"eventAppraise": null,
				"eventType": "2",
				"instanceId": "170029",
				"tanentId": "100",
				"eventSource": "民众上报",
				"eventCategory": "测试大类2",
				"eventSubclass": "1111",
				"flowName": null,
				"lon": "118.822585",
				"lat": "32.043644",
				"handle": "2",
				"clsx": null,
				"name": null,
				"currentNodeId": "0a8f16cb68124b1b8f8d31b8d41aba47",
				"nextNodeId": "0c1a7853d1654d9fa9ca320ceac0d394",
				"satisfaction": null,
				"satisfactionRemark": null,
				"img": null,
				"imgIds": null,
				"bs": null
			}, ],
			"code": 200,
			"msg": "查询成功"
		})
	})
}

/**
 * @description 事件详情 
 */
export const eventDetail = (params, config = {}) => {
	return http.get(`/weChatApp/${params.id}`, handleParams(config));
	return new Promise((resolve) => {
		resolve({
			code: 200,
			data: {
				"img": [],
				"data": {
					"createBy": "25",
					"createTime": "2023-03-20 10:22:05",
					"updateBy": null,
					"updateTime": "2023-03-20 10:22:05",
					"remark": null,
					"delFlag": "0",
					"tenantId": null,
					"eventId": "bcfda3d09833444e9990f02ac1987419",
					"eventName": "测试事件8",
					"eventTypeId": "10118",
					"eventPeopleNum": 2,
					"eventDescribe": "事件描述8",
					"eventLevel": "1",
					"eventLocation": "哈尔滨市测试地址",
					"eventHandler": "18",
					"eventStatus": "2",
					"eventAppraise": null,
					"eventType": "2",
					"instanceId": "170013",
					"tanentId": "100",
					"eventSource": "民众上报",
					"eventCategory": "测试大类2",
					"eventSubclass": "1111",
					"flowName": null,
					"lon": "118.822585",
					"lat": "32.043644",
					"handle": "2",
					"clsx": null,
					"name": null,
					"currentNodeId": null,
					"nextNodeId": null,
					"satisfaction": null,
					"satisfactionRemark": null,
					"img": null,
					"imgIds": null,
					"bs": null
				},
				"user": [{
					"user_id": 25,
					"dept_id": null,
					"user_name": "18989898989",
					"nick_name": "路人丁",
					"user_number_id": "230102198809091618",
					"user_type": "02",
					"email": "",
					"phonenumber": "18989898989",
					"sex": "1",
					"avatar": "30",
					"password": "$2a$10$NlldAQWXHoBKdlzclw1qZut703g1S01LikGf0xSdkUFTcRlVUwsL6",
					"status": "0",
					"del_flag": "0",
					"login_ip": "192.168.0.11",
					"login_date": "2023-03-21T15:55:34",
					"create_by": "",
					"create_time": "2023-03-17T15:51:32",
					"update_by": "",
					"update_time": "2023-03-21T15:55:34",
					"remark": null
				}],
				"flow": [{
						"event_id": "bcfda3d09833444e9990f02ac1987419",
						"event_name": "测试事件8",
						"event_type_id": "10118",
						"event_people_num": 2,
						"event_describe": "事件描述8",
						"event_level": "1",
						"event_location": "哈尔滨市测试地址",
						"event_handler": "18",
						"event_status": "2",
						"event_appraise": null,
						"lat": "32.043644",
						"lon": "118.822585",
						"event_type": "2",
						"instance_id": "170013",
						"del_flag": "0",
						"create_time": "2023-03-20T10:22:05",
						"update_by": null,
						"create_by": "25",
						"update_time": "2023-03-20T10:22:05",
						"remark": null,
						"tanent_id": "100",
						"event_source": "民众上报",
						"event_subclass": "1111",
						"event_category": "测试大类2",
						"handle": "2",
						"current_node_id": "0a8f16cb68124b1b8f8d31b8d41aba47",
						"next_node_id": "0c1a7853d1654d9fa9ca320ceac0d394",
						"satisfaction": null,
						"satisfaction_remark": null,
						"depoly_id": "flow_13ukfemg:1:170004",
						"category": "flow_13ukfemg:1:170004",
						"flow_type": "1",
						"task_id": "0a8f16cb68124b1b8f8d31b8d41aba47",
						"task_name": "ceshi1",
						"task_node_type": "1",
						"task_deal_type": "2",
						"task_action": "2,1",
						"task_time": 86400000,
						"task_user": null,
						"task_representation": null,
						"text_data": "核实通过",
						"file_data": "21",
						"sort": 1,
						"flow_action_name": "1",
						"flow_action_time": "2023-03-21T13:39:37",
						"flow_action_user": "1",
						"flow_sts": "1",
						"flow_action_user_name": "管理员",
						"create_name": "路人丁"
					},
					{
						"event_id": "bcfda3d09833444e9990f02ac1987419",
						"event_name": "测试事件8",
						"event_type_id": "10118",
						"event_people_num": 2,
						"event_describe": "事件描述8",
						"event_level": "1",
						"event_location": "哈尔滨市测试地址",
						"event_handler": "18",
						"event_status": "2",
						"event_appraise": null,
						"lat": "32.043644",
						"lon": "118.822585",
						"event_type": "2",
						"instance_id": "170013",
						"del_flag": "0",
						"create_time": "2023-03-20T10:22:05",
						"update_by": null,
						"create_by": "25",
						"update_time": "2023-03-20T10:22:05",
						"remark": null,
						"tanent_id": "100",
						"event_source": "民众上报",
						"event_subclass": "1111",
						"event_category": "测试大类2",
						"handle": "2",
						"current_node_id": "0a8f16cb68124b1b8f8d31b8d41aba47",
						"next_node_id": "0c1a7853d1654d9fa9ca320ceac0d394",
						"satisfaction": null,
						"satisfaction_remark": null,
						"depoly_id": "flow_13ukfemg:1:170004",
						"category": "flow_13ukfemg:1:170004",
						"flow_type": "1",
						"task_id": "0c1a7853d1654d9fa9ca320ceac0d394",
						"task_name": "ceshi2",
						"task_node_type": "0",
						"task_deal_type": "1",
						"task_action": "3,4",
						"task_time": 172800000,
						"task_user": null,
						"task_representation": "${start==0},${start==1}",
						"text_data": null,
						"file_data": null,
						"sort": 2,
						"flow_action_name": null,
						"flow_action_time": null,
						"flow_action_user": null,
						"flow_sts": "0",
						"create_name": "路人丁"
					},
					{
						"event_id": "bcfda3d09833444e9990f02ac1987419",
						"event_name": "测试事件8",
						"event_type_id": "10118",
						"event_people_num": 2,
						"event_describe": "事件描述8",
						"event_level": "1",
						"event_location": "哈尔滨市测试地址",
						"event_handler": "18",
						"event_status": "2",
						"event_appraise": null,
						"lat": "32.043644",
						"lon": "118.822585",
						"event_type": "2",
						"instance_id": "170013",
						"del_flag": "0",
						"create_time": "2023-03-20T10:22:05",
						"update_by": null,
						"create_by": "25",
						"update_time": "2023-03-20T10:22:05",
						"remark": null,
						"tanent_id": "100",
						"event_source": "民众上报",
						"event_subclass": "1111",
						"event_category": "测试大类2",
						"handle": "2",
						"current_node_id": "0a8f16cb68124b1b8f8d31b8d41aba47",
						"next_node_id": "0c1a7853d1654d9fa9ca320ceac0d394",
						"satisfaction": null,
						"satisfaction_remark": null,
						"depoly_id": "flow_13ukfemg:1:170004",
						"category": "flow_13ukfemg:1:170004",
						"flow_type": "1",
						"task_id": "55ce1771538f4ee69a4dfdbaa9922d36",
						"task_name": "ceshi3",
						"task_node_type": "1",
						"task_deal_type": "1",
						"task_action": "5,6",
						"task_time": 172800000,
						"task_user": null,
						"task_representation": null,
						"text_data": null,
						"file_data": null,
						"sort": 3,
						"flow_action_name": null,
						"flow_action_time": null,
						"flow_action_user": null,
						"flow_sts": "0",
						"create_name": "路人丁"
					}
				]
			}
		})
	})
}

/**
 * @description 事件评价 
 */
export const subRate = (params, config = {}) => http.post('/weChatApp/eventSatisfaction', params, handleParams(config))

/**
 * @description 事件列表
 * @param {Number} pageNum
 * @param {Number} pageSize
 * @param {String} createBy 当前登录人id this.$store.state.user.userInfo.userId
 */
export const getEventList = (params, config = {}) => http.get('/weChatApp/listAlls', formatGetParams({
	params: Object.assign({}, {
		createBy: Store.state.user.userInfo?.userId,
		eventStatusBs: "1"
	}, params),
	config
}))

/**
 * @description 事件跟踪列表
 * @param {Number} pageNum
 * @param {Number} pageSize
 * @param {String} userId 当前登录人id this.$store.state.user.userInfo.userId
 */
export const getEventFollowList = (params, config = {}) => http.post('/weChatApp/eventTracking', Object.assign({}, {
	userId: Store.state.user.userInfo?.userId
}, params), handleParams(config))

/**
 * @description 事件列表-处理中(我的待办)
 * @param {Number} pageNum
 * @param {Number} pageSize
 * @param {String} userId 当前登录人id this.$store.state.user.userInfo.userId
 */
export const getEventDoingList = (params, config = {}) => http.post('/MyToDo/list', Object.assign({}, {
	userId: Store.state.user.userInfo?.userId
}, params), handleParams(config))

/**
 * @description 事件列表-历史待办
 * @param {Number} pageNum
 * @param {Number} pageSize
 * @param {String} userId 当前登录人id this.$store.state.user.userInfo.userId
 */
export const getEventHistoryDoingList = (params, config = {}) => http.post('/MyToDo/historicalToDoList', Object.assign({}, {
	userId: Store.state.user.userInfo?.userId
}, params), handleParams(config))

/**
 * @description 事件列表-已办结
 * @param {Number} pageNum
 * @param {Number} pageSize
 * @param {String} userId 当前登录人id this.$store.state.user.userInfo.userId
 */
export const getEventFinallyList = (params, config = {}) => http.post('/MyToDo/verifiedList', Object.assign({}, {
	userId: Store.state.user.userInfo?.userId
}, params), handleParams(config))

/**
 * @description 获取当前节点可用功能(工作人员权限)
 * @param {String} currentNodeid 当前节点id
 */
export const getCurrentNodeActions = (params, config = {}) => http.get('/weChatApp/eventAction', formatGetParams({
	params,
	config
}))

/**
 * @description 待办事件处理(工作人员权限)
 * @param {String} eventHandler 下一节点处理人
 * @param {String} eventId 事件id
 * @param {String} taskAction 节点动作 如果节点动作中有3、4 。则需要传参数start。节点动作为3 start： 1.节点动作为4 start：0
 * @param {String} textData 处理信息
 * @param {Array} fileData 图片集合
 */
export const setEventHandle = (params, config = {}) => {
	if ([3, 4].includes(params.taskAction)) {
		params.start = params.taskAction === 3 ? 1 : 0
	} else delete params.start
	console.log("setEventHandle-params", params);
	// return Promise.resolve({
	// 	code: 200
	// })
	return http.post('/flowable/flow/claim', params, handleParams(config))
}

/**
 * @description 获取统一固定流程信息
 */
export const getTylc = (params, config = {}) => http.get('/weChatAppUser/tylc', formatGetParams({
	params,
	config
}))










// /** 事件大类 */
//     @Excel(name = "事件大类")
//     private String eventCategory;

//     /** 事件小类 */
//     @Excel(name = "事件小类")
//     private String eventSubclass;
// lat 纬度
// lon 经度
// /** 事件id */
//     private String eventId;

//     /** 事件名称 */
//     @Excel(name = "事件名称")
//     private String eventName;

//     /** 事件类型 */
//     @Excel(name = "事件类型")
//     private String eventTypeId;

//     /** 涉及人数 */
//     @Excel(name = "涉及人数")
//     private Long eventPeopleNum;

//     /** 事件描述 */
//     @Excel(name = "事件描述")
//     private String eventDescribe;

//     /** 事件程度 */
//     @Excel(name = "事件程度")
//     private String eventLevel;

//     /** 事件发生位置 */
//     @Excel(name = "事件发生位置")
//     private String eventLocation;

//     /** 下一环节处理人 */
//     @Excel(name = "下一环节处理人")
//     private String eventHandler;

//     /** 事件状态(0 : 督办，1：评价） */
//     @Excel(name = "事件状态(0 : 督办，1：评价）")
//     private String eventStatus;

//     /** 事件评价 */
//     @Excel(name = "事件评价")
//     private String eventAppraise;

//     /** 事件环节处理方式(按部门，按网格，按人员） */
//     @Excel(name = "事件环节处理方式(按部门，按网格，按人员）")
//     private String eventType;

//     /** 流程实例ID */
//     @Excel(name = "流程实例ID")
//     private String instanceId;

//     /** 删除状态（0：启用，1：删除） */
//     private String delFlag;

//     /** 租户id */
//     @Excel(name = "租户id")
//     private String tanentId;

//     /** 上报人 */
//     @Excel(name = "上报人")
//     private String createBy;

//     /** 事件来源 */
//     @Excel(name = "事件来源")
//     private String eventSource;


//     /**
//      * 图片id
//      */
//     private List imgIds;